<template>
	<view class="fistView">
		<view class="headView"></view>

		<view class="fistCard" v-for="item in groupList" :key="item.id" @click="goGroupcountDetail(item.id)">
			<uni-card>
				<image :src="item.img" style="width: 100%;"></image>
				<view class="underImage">
					<view>{{item.title}}</view>
					<navigator>
						<view class="xiangqing">
							<view>详情</view>
							<image src="../../../static/images/右箭头 (1).png"></image>
						</view>
					</navigator>
				</view>
			</uni-card>
		</view>


	</view>
</template>

<script>
	import request from '../../../uitls/request';
	export default {
		data() {
			return {
				groupList:[]
			}
		},
		onLoad() {
			this.loadGroupData();
		},
		methods: {
			loadGroupData() {
						request({
							url: '/offer/purchase/list',
							method: 'GET',
							params:{
								pageNum:1,
								pageSize:10,
							},
							header:{
								'Authorization':uni.getStorageSync('token')
							},
							success: (res) => {
								if (res.data.code === 200) {
									this.groupList = res.data.rows;
									uni.showToast({
										title:'加载成功',
										icon:'success',
									});
									console.log(this.groupList);
								} else {
									uni.showToast({
										title: res.data.message || '注册失败',
										icon: 'none'
									});
								}
							},
							fail: (err) => {
								console.error('请求失败', err);
								uni.showToast({
									title: '网络错误',
									icon: 'none'
								});
							}
						});
					},
			goGroupcountDetail(id){
				uni.navigateTo({
					url:'/pages/user3/groupcount/groupcount?id='+id
				})
			}
		}
	}
</script>

<style>
	.headView {
		height: 300rpx;
		background-color: #5290ff;
	}
	/* 卡片 */
	.fistCard{
		/* background-color: rebeccapurple; */
		margin-top: -280rpx;
		margin-bottom: 320rpx;
	}
	.fistCard .underImage{
		display: flex;
		justify-content: space-between;
	}
	.fistCard .underImage >view:first-child{
		color: black;
		
	}
	.fistCard .underImage .xiangqing{
		display: flex;
		/* background-color: rebeccapurple; */
		align-items: center;
	}
	.fistCard .underImage .xiangqing image{
		width: 28rpx;
		height: 28rpx;
		margin-left: 8rpx;
	}
	.fistCard .underImage .xiangqing view{
		color: gray;
	}
	
</style>